#include <stdio.h>
#include <stdlib.h>

#include "ldk_learn_jni_AccessFieldsJni.h"

JNIEXPORT
void JNICALL Java_ldk_learn_jni_AccessFieldsJni_call(JNIEnv *env, jclass clazz, jobject this){
	static jfieldID nameField = NULL;
	static jfieldID age = NULL;
	if (nameField == NULL){
		nameField = (*env)->GetFieldID(env, clazz, "name", "Ljava/lang/String;");
		age = (*env)->GetFieldID(env, clazz, "age", "I");
		if (nameField == NULL || age == NULL){
			printf("反射获取属性失败");
			exit(-1);
		}
	}
	(*env)->SetObjectField(env, this, nameField, (*env)->NewStringUTF(env, "中文, english"));
	(*env)->SetIntField(env, this, age, 100);
}

